@import "../../../assets/sass/variables";

.free-switch {

  position: relative;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;

  >input {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
  }

  input[type='checkbox']:checked + .free-switch-media .switch-label {
    background: #1ABC9C;

    &:after {
      background: #1ABC9C;
      -webkit-transform: translate3d(1rem, 0, 0);
      transform: translate3d(1rem, 0, 0);
    }
  }

  .free-switch-inner {
    -webkit-flex: 1;
    flex: 1;
    padding: 0.5rem;
    order: 3;
  }

  .switch-label {
    position: relative;
    display: block;
    width: 2.5rem;
    height: 1.5rem;
    border-radius: 999px;
    background: #aaa;
    -webkit-transition: all 0.35s;
    transition: all 0.35s;

    &:before,
    &:after {
      content: '';
      position: absolute;
      -webkit-transition: all 0.35s;
      transition: all 0.35s;
    }

    &:after {
      top: 4px;
      left: 4px;
      bottom: 4px;
      width: 1.1rem;
      background: #aaa;
      border-radius: 50%;
      -webkit-transform: translate3d(0, 0, 0);
      transform: translate3d(0, 0, 0);
    }

    &:before {
      background: #fff;
      top: 2px;
      left: 2px;
      right: 2px;
      bottom: 2px;
      border-radius: 999px;
    }
  }

  .free-switch-media {
    -webkit-order: 2;
    order: 2;
    display: -moz-box;
    display: -webkit-box;
    display: -ms-flexbox;
    display: -webkit-flex;
    display: flex;
    -webkit-box-align: center;
    -webkit-align-items: center;
    align-items: center;
    margin-left: 3px;
  }

  &.free-switch-2 {
    .switch-label {
      width: 2rem;
      background: transparent !important;

      &:before {
        background: rgb(189, 189, 189);
        top: 0.45rem;
        bottom: 0.45rem;
        left: 0;
        right: 0;
      }

      &:after {
        background: rgb(245, 245, 245);
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.28);
        left: 0;
      }
    }

    input[type='checkbox']:checked+.free-switch-media .switch-label {
      background: #fff;

      &:before {
        background: #1ABC9C;
      }

      &:after {
        background: #fff;
        -webkit-transform: translate3d(1rem, 0, 0);
        transform: translate3d(1rem, 0, 0);
      }
    }
  }

  &.free-switch-3 {
    .switch-label {
      background: #fff;

      &:before {
        background: transparent;
        border: solid 2px #e6e6e6;
        top: 0;
        bottom: 0;
        left: 0;
        right: 0;
      }

      &:after {
        background: #fff;
        box-shadow: 0 2px 7px rgba(0, 0, 0, 0.35), 0 1px 1px rgba(0, 0, 0, 0.15);
      }
    }

    input[type='checkbox']:checked+.free-switch-media .switch-label {
      &:after {
        background: #fff;
        box-shadow: 0 2px 7px rgba(0, 0, 0, 0.35), 0 1px 1px rgba(0, 0, 0, 0.15);
      }

      &:before {
        border-color: #1ABC9C;
      }
    }
  }

  @each $name, $color in $theme {
    &.free-#{$name} {
      input[type='checkbox']:checked+.free-switch-media .switch-label {
        background: $color;

        &:after {
          background: $color;
        }
      }

      &.free-switch-2 {
        input[type='checkbox']:checked+.free-switch-media .switch-label:before {
          background: $color;
        }
      }

      &.free-switch-3 {
        input[type='checkbox']:checked+.free-switch-media .switch-label:before {
          border-color: $color;
        }
      }
    }
  }

  $color: rgba(170, 170, 170, .4) !important;
  input[type='checkbox']:disabled + .free-switch-media .switch-label {
    background: $color;
    &:after {
      background: $color;
    }
  }
}
